
use Data/event_study_samplewithsolar.dta, clear

  
	merge m:1 postcode using Data/Estimation_postcodes.dta
	
	keep if _merge ==3
  
  
	keep ROOFME module P* ROOFTI *_end* *_start* cum new has ever median* contract_quarter postcode green_plan hhid account_id price*
  
	xtset postcode

  
  
	gen quarter = contract_quarter
 
	gen roofIV = (ROOFME/module)/1000

	gen nexis_buildings  = ROOFME/PROOFME
		
		
	gen roofratio = ROOFME/ROOFTI
	gen roofratiobuildings = roofratio*nexis_buildings
		
	gen roofrelativeIV = (roofratio*nexis_buildings/[moduleprice])/1000

		
collapse (firstnm) postcode account_id (mean) price* median* P* roofrelative* ROOFME module ROOFTI SHCP* SRES* FFIT* cum new ever    (max) has green_plan , by(hhid quarter)

	
save Data/Individual_withsolar.dta, replace
	
	
	
